<?php
/**
 * 会员广告位管理 - 织梦技术研究中心！
 *
 * @version        $Id: myad.php 14:31:15 2013年10月10日 土匪 $
 * @package        DedeCMS menber ad
 * @copyright      Copyright (c) 2013, Dedejs.com
 * @link           http://bbs.dedejs.com
 */

require_once(dirname(__FILE__)."/config.php");
CheckRank(0,0);
$menutype = 'mydede';
require_once(DEDEINC."/datalistcp.class.php");
setcookie("ENV_GOBACK_URL",$dedeNowurl,time()+3600,"/");
$ntime=time();

$query = "Select cid,price,adtype,mcid,times,starttime,endtime,normbody,normurl FROM #@__memad  where cid='$cid' and mcid='$cfg_ml->M_ID' limit 1 ";
$sector = $dsql->GetOne($query);
$mones= $sector['times'] * $sector['price'];
if($action == 'edit')
{
	if(!is_array($sector))
	{
		ShowMsg("读取购买服务出错！请将该错误提交到织梦技术研究中心！","-1");
		exit();
	}
	if($ntime > $sector['endtime'] || $ntime < $sector['starttime'])
	{
		ShowMsg("你购买的广告位已到期!","-1");
		exit();
	}
	if(empty($step))
	{
	if($sector['adtype']=='1'){
	$nbody = "<tr><td width=150 height=35 align=right bgcolor=#FFFFFF>文字内容：</td><td bgcolor=#FFFFFF>&nbsp;&nbsp;<input name=normbody type=text style='height:20px;font-size:14px; line-height:23px;' size=50 value={$sector['normbody']} ></td></tr><tr><td width=150 height=35 align=right bgcolor=#FFFFFF>文字链接：</td><td bgcolor=#FFFFFF>&nbsp;&nbsp;<input name=normurl type=text style='height:20px;font-size:14px; line-height:23px;' size=50 value={$sector['normurl']} ></td></tr>";
	
	}
    elseif($sector['adtype']=='2'){
    $nbody = "<tr><td width=150 height=35 align=right bgcolor=#FFFFFF>图片地址：</td><td bgcolor=#FFFFFF>&nbsp;&nbsp;<input name=normbody type=text style='height:20px;font-size:14px; line-height:23px;' size=50 value={$sector['normbody']}> <input name=pic_bt type=button class=intxt style='width:150px;height:23px;' value=从上传附件中选择 onClick=SelectImage('form2.normbody','big') /></td></tr><tr><td width=150 height=35 align=right bgcolor=#FFFFFF>图片链接：</td><td bgcolor=#FFFFFF>&nbsp;&nbsp;<input name=normurl type=text style='height:20px;font-size:14px; line-height:23px;' size=50 value={$sector['normurl']} ></td></tr>";
   
     }
     else{
	$nbody = "<tr><td width=150 height=35 align=right bgcolor=#FFFFFF>Flash地址：</td><td bgcolor=#FFFFFF>&nbsp;&nbsp;<input name=normbody type=text style='height:20px;font-size:14px; line-height:23px;' size=50 value={$sector['normbody']}> <input name=pic_bt type=button class=intxt style='width:150px;height:23px;' value=从上传附件中选择 onClick=SelectFlash('form2.normbody','big') /> </td></tr>";
	
    }
}
else if($step == 2){
   if($adtype == 2 && ( (ereg(':',$normbody) && !eregi('^http:',$normbody)) || !eregi("\.(jpg|png|gif)",$normbody)))
	 {
		ShowMsg('你指定的图片网址存在问题！','-1');
		exit();
	 }
	if($adtype == 3 && ( (ereg(':',$normbody) && !eregi('^http:',$normbody)) || !eregi("\.(swf)",$normbody)))
	 {
		ShowMsg('你指定的Flash网址存在问题！','-1');
		exit();
	 }

else{
	$query = "update `#@__memad` set normbody='$normbody',normurl='$normurl' where cid='$cid' ";
	if($dsql->ExecuteNoneQuery($query))
		{
			ShowMsg('修改广告位成功，将返回管理页面','myad.php');
			exit();
		}
		else
		{
			ShowMsg('修改失败，请将该错误提交到织梦技术研究中心！','myad.php');
			exit();
		}
	}
}
	include(DEDEMEMBER."/templets/myad.htm");
		exit();
}
$wheresql=" WHERE mcid='$cfg_ml->M_ID'";
$query = "SELECT c.*,m.name FROM #@__memad c left join #@__memad_type m on c.tid=m.aid $wheresql order by c.tid,c.lists ";
$dlist = new DataListCP();
$dlist->pageSize = 10;
$dlist->SetTemplate(DEDEMEMBER."/templets/myad.htm");
$dlist->SetSource($query);
$dlist->Display();

?>